package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.net.mapper.ElementAlarmMapper;
import com.ruoyi.net.domain.ElementAlarm;
import com.ruoyi.net.service.IElementAlarmService;

/**
 * 网元-告警Service业务层处理
 * 
 * @author net
 * @date 2024-11-17
 */
@Service
public class ElementAlarmServiceImpl implements IElementAlarmService 
{
    @Autowired
    private ElementAlarmMapper elementAlarmMapper;

    /**
     * 查询网元-告警
     * 
     * @param id 网元-告警主键
     * @return 网元-告警
     */
    @Override
    public ElementAlarm selectElementAlarmById(String id)
    {
        return elementAlarmMapper.selectElementAlarmById(id);
    }

    /**
     * 查询网元-告警列表
     * 
     * @param elementAlarm 网元-告警
     * @return 网元-告警
     */
    @Override
    public List<ElementAlarm> selectElementAlarmList(ElementAlarm elementAlarm)
    {
        return elementAlarmMapper.selectElementAlarmList(elementAlarm);
    }

    /**
     * 新增网元-告警
     * 
     * @param elementAlarm 网元-告警
     * @return 结果
     */
    @Override
    public int insertElementAlarm(ElementAlarm elementAlarm)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(elementAlarm.getId())) {
            elementAlarm.setId(uuid);
        }
        elementAlarm.setCreateBy("admin");
        elementAlarm.setCreateTime(DateUtils.getNowDate());
        elementAlarm.setUpdateBy("admin");
        elementAlarm.setUpdateTime(DateUtils.getNowDate());
        return elementAlarmMapper.insertElementAlarm(elementAlarm);
    }

    /**
     * 修改网元-告警
     * 
     * @param elementAlarm 网元-告警
     * @return 结果
     */
    @Override
    public int updateElementAlarm(ElementAlarm elementAlarm)
    {
        elementAlarm.setUpdateBy(SecurityUtils.getUsername());
        elementAlarm.setUpdateTime(DateUtils.getNowDate());
        return elementAlarmMapper.updateElementAlarm(elementAlarm);
    }

    public int updateElementAlarmRemove(ElementAlarm elementAlarm) {
        elementAlarm.setUpdateTime(DateUtils.getNowDate());
        return elementAlarmMapper.updateElementAlarmRemove(elementAlarm);
    }

    /**
     * 批量删除网元-告警
     * 
     * @param ids 需要删除的网元-告警主键
     * @return 结果
     */
    @Override
    public int deleteElementAlarmByIds(String[] ids)
    {
        return elementAlarmMapper.deleteElementAlarmByIds(ids);
    }

    /**
     * 删除网元-告警信息
     * 
     * @param id 网元-告警主键
     * @return 结果
     */
    @Override
    public int deleteElementAlarmById(String id)
    {
        return elementAlarmMapper.deleteElementAlarmById(id);
    }

    /**
     * 批量新增网元-告警
     *
     * @param alarms 网元-告警集合
     * @return 结果
     * @param alarms
     * @return
     */
    @Override
    public int insertElementAlarms(List<ElementAlarm> alarms) {
        return elementAlarmMapper.insertElementAlarms(alarms);
    }

    @Override
    public int deleteElementAlarmByDelFlag() {
        return elementAlarmMapper.deleteElementAlarmByDelFlag();
    }

    @Override
    public int updateAlarmsDeletedByElementId(String elementId) {
        return elementAlarmMapper.updateAlarmsDeletedByElementId(elementId);
    }
}
